﻿<Window x:Class="TfsBacklogMgr.Main.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:TfsBacklogMgr.Main"
        xmlns:dd="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
        xmlns:extToolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended"
        Icon="pictures\icon.png"
        Title="TFS Backlog Wrangler" Height="350" Width="525" Loaded="MainWindow_Loaded" Closed="MainWindow_Closing" Closing="MainWindow_IsClosing">

    <Window.Resources>
        <local:BoolToVisibilityConverter x:Key="visibilityConverter" />
        <local:BoolToInvisibilityConverter x:Key="invisibilityConverter" />
        <!--<HierarchicalDataTemplate 
      x:Key="OrderTemplate"
      ItemsSource="{Binding Path=OrderDetails}"
      ItemTemplate="{StaticResource OrderDetailTemplate}"
      >
            <TextBlock Text="{Binding Path=Desc}" />
 </HierarchicalDataTemplate>-->
    </Window.Resources>


    <extToolkit:BusyIndicator Name="BusyWarning" IsBusy="False" >
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <Label Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Content="{Binding Path=TfsPath}" Visibility="{Binding Path=TfsIsConnected, Converter={StaticResource visibilityConverter}}"></Label>
        <Button Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Content="Connect to TFS" Visibility="{Binding Path=TfsIsConnected, Converter={StaticResource invisibilityConverter}}" Click="ConnectToTfs_Click" />
            
        <StackPanel Grid.Column="0" Grid.Row="1" >
            <Label Content="Sprint Iterations:"></Label>            
            <ComboBox 
                      Name="_CurrentIter"
                      ItemsSource="{Binding Path=NonLeafIterations}"
                      SelectedItem="{Binding Path=CurrentSprintIteration}"
                      DisplayMemberPath="Path"
                      IsEnabled="{Binding Path=TfsIsConnected}"
                      >
            
            </ComboBox>
        </StackPanel>



        <TreeView Grid.Column="0" Grid.Row="2"
                 Name="_SprintTree" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" 
                 VerticalAlignment="Stretch" 
                 ItemContainerStyle="{StaticResource StretchyTreeViewItemStyle}"                   
                 ItemsSource="{Binding Path=CurrentSprintIteration.SprintChildren}"  
                 ItemTemplateSelector="{StaticResource theSprintDataTemplateSelector}"
                 ScrollViewer.IsDeferredScrollingEnabled="False"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 ScrollViewer.VerticalScrollBarVisibility="Visible" 
                 IsEnabled="{Binding Path=TfsIsConnected}"
                 dd:DragDrop.IsDragSource="True" 
                 dd:DragDrop.IsDropTarget="True"    dd:DragDrop.DropHandler="{Binding}"          >
        </TreeView>
        
        <GridSplitter HorizontalAlignment="Right" 
                  VerticalAlignment="Stretch" 
                  Grid.Column="1" Grid.Row="2" ResizeBehavior="PreviousAndNext"
                  Width="5" Background="#FFBCBCBC"/>


        <StackPanel Grid.Column="2" Grid.Row="1" >
            <Grid>
                <Label>
                    <Hyperlink Click="SelectIterations_Click" IsEnabled="{Binding Path=TfsIsConnected}">Uncommitted Backlog Iterations:</Hyperlink></Label>

            </Grid>
            <ComboBox 
                      Name="_BacklogIter"
                      ItemsSource="{Binding Path=BacklogIterations}"
                      SelectedItem="{Binding Path=CurrentBacklogIteration}"
                      DisplayMemberPath="Path"
                      IsEnabled="{Binding Path=TfsIsConnected}"
                      >

            </ComboBox>
        </StackPanel>

        <TreeView Grid.Column="2" Grid.Row="2"
                 Name="_BacklogTree" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" 
                 VerticalAlignment="Stretch" 
                 ItemContainerStyle="{StaticResource StretchyTreeViewItemStyle}"                   
                 ItemsSource="{Binding Path=CurrentBacklogIteration.BacklogChildren}"  
                 ItemTemplateSelector="{StaticResource theBacklogDataTemplateSelector}" 
                 ScrollViewer.IsDeferredScrollingEnabled="False"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                 ScrollViewer.VerticalScrollBarVisibility="Visible" 
                 IsEnabled="{Binding Path=TfsIsConnected}"
                 dd:DragDrop.IsDragSource="True" 
                 dd:DragDrop.IsDropTarget="True"        dd:DragDrop.DropHandler="{Binding}"         >
        </TreeView>

        <ListBox Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="3"
                 ItemsSource="{Binding Path=ChosenUsers}"
                 ItemTemplate="{StaticResource UserTemplate}" 
                 MouseDoubleClick="User_DoubleClick" 
                 IsSynchronizedWithCurrentItem="True"
                 SelectedItem="{Binding Path=CurrentUser}"
                 dd:DragDrop.IsDragSource="True" 
                 dd:DragDrop.IsDropTarget="True"    dd:DragDrop.DropHandler="{Binding}"          >
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel Orientation="Horizontal" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
        </ListBox>
        <Button Grid.Row="4" 
                IsEnabled="{Binding Path=TfsIsConnected}"
                Click="SelectUsers_Click" Margin="0,0,166,0">Select Users</Button>
    </Grid>
    </extToolkit:BusyIndicator>

</Window>
